/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package etherblocks.engine.states;

import com.jme3.app.Application;
import com.jme3.app.state.AppStateManager;
import etherblocks.engine.network.*;

/**
 *
 * @author Carl
 */
public class GameStartedAppState extends BaseAppState{

    public GameStartedAppState(){
        
    }

    @Override
    public void initialize(AppStateManager stateManager, Application application){
        super.initialize(stateManager, application);
        NetworkAppState networkAppState = getAppState(NetworkAppState.class);
        NetworkClient networkClient = networkAppState.getNetworkClient();
        if(networkClient.isServer()){
            final NetworkServer networkServer = (NetworkServer) networkClient;
            mainApplication.enqueueTask(new Runnable(){

                public void run(){
                    networkServer.getGameServer().onGameStarted();
                }
            });
        }
        ModAppState modAppState = getAppState(ModAppState.class);
        modAppState.getMod().onGameStarted();
        mainApplication.getStateManager().detach(this);
    }
}
